<template>

    <el-table
      :data="tableData.filter(data => !search || data.tname.toLowerCase().includes(search.toLowerCase()))"
      stripe
      style="width: 100%">
      <el-table-column
        prop="tid"
        label="流派ID"
        width="200">
      </el-table-column>
      <el-table-column
        prop="tname"
        label="流派名称"
        width="200">
      </el-table-column>
      <el-table-column
        prop="tdesc"
        label="描述"
        width="500">
      </el-table-column>
      <el-table-column align="right">
      <template slot="header" slot-scope="scope">
        <el-input
          v-model="search"
          size="mini"
          placeholder="输入关键字搜索"/>
      </template>
      <template slot-scope="scope">
        <el-button
          size="mini"
          @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
        <el-button
          size="mini"
          type="danger"
          @click="handleDelete(scope.$index, scope.row)">删除</el-button>
      </template>
    </el-table-column>
    </el-table>

  </template>

<script>

export default {
  data() {
    return {
      tableData: [],
      search: "",
    };
  },
  created() {
    this.getTableData()
  },
  methods: {
    handleEdit(index, row) {
      console.log(index, row);
    },
    handleDelete(index, row) {
      console.log(index, row);
    },
    async getTableData() {
      const resAllData = await this.$http.get('music/mtype',{params:{sname:""}});
      this.tableData = resAllData.data.data;
      console.log(this.tableData);
    },
  },
};
</script>
